/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idoms;

import java.util.Arrays;
import java.util.Objects;

/**
 *
 * @author Ngocvan
 */
public class Person implements Comparable<Person> {

    String name;
    int birthYear;
    byte[] raw;

    public Person() {
        this("Noname", 1987);
    }

    public Person(String name, int birthYear) {
        this.name = name;
        this.birthYear = birthYear;
        this.raw = null;
    }

    @Override
    public boolean equals(Object obj){
        if (!(obj instanceof Person))
            return false;
        
        Person other = (Person) obj;
        return name.equals(other.name)
                    && birthYear == other.birthYear
                    && Arrays.equals(raw, other.raw);
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 41 * hash + Objects.hashCode(this.name);
        hash = 41 * hash + this.birthYear;
        hash = 41 * hash + Arrays.hashCode(this.raw);
        return hash;
    }

    @Override
    public int compareTo(Person t) {
        return (birthYear - t.birthYear);
    }
}
